{include file="header.html"}
<style type="text/css">
.gm-span{ display: inline-block;width: 50px;text-align: center;text-align: right;padding-right: 3px;}
.gm-span2{ width: 46px;}
.search > input{ width: 160px;}
.red{ color: red;}
#checkboss{ width: 100%;height: 100%;cursor: pointer;text-align: center;}
.fot{ text-align: center;background: none;}
</style>
<div class="page-header">
	<h6>
		商品列表
		<small>
			<i class="ace-icon fa fa-angle-double-right"></i>
			商品列表
		</small>
	</h6>
</div><!-- /.page-header --> 
<div style="margin-top:30px;">
	<form action="?" method="get">
	<div class="search">
	<input type="hidden" name="app" id="app" value="goods" />
	<input type="hidden" name="act" id="act" value="index" />
	<input type="hidden" name="jiage" id="jiage" value="" /> 
	<span class="gm-span"> ID : </span><input type="text" name="id" id="id" value="{$id}" /> 
	<span class="gm-span"> 关键词 : </span><input type="text" name="keyword" id="keyword" value="{$keyword}" /> 
	<span class="gm-span"> 货号 : </span><input type="text" name="huohao" id="huohao" value="{$huohao}" /> <br />
	<span class="gm-span"> 价格 : </span><input type="text" name="startprice" id="startprice" value="{$startprice}" />
	<span class="gm-span" style="text-align: center">---</span><input type="text" name="endprice" id="endprice" value="{$endprice}"/>
	<span class="gm-span gm-span2"></span>
	<select name="shop_id" id="shop_id" class=" form-control "  data-live-search="true" style="line-heght:30px;display:inline-block;width:160px;">
	<option value=""> 门店 </option>
	{foreach from=$shops  item=shop}
	<option value="{$shop->id}" {if $shop->id == $shop_id}selected{/if}>{$shop->name}</option>
	{/foreach}
	</select>
	<select name="cate_id" id="cate" class=" form-control "  data-live-search="true" style="line-heght:30px;display:inline-block;width:160px;">
		<option value=""> 分类: </option>
		{foreach from = $cate_parent item =val}
			<optgroup label="{$val->name}">
				{foreach from = $cate item =row}
					{if $row->parent_id == $val->id}
					<option value="{$row->id}" {if $cate_id == $row->id}selected{/if}>{$row->name}</option>
					{/if}
				{/foreach}
			</optgroup>
		{/foreach}
	</select>
<!-- 	<select name="cate_boss" id="shop_id" class=" form-control "  data-live-search="true" style="line-heght:30px;display:inline-block;width:160px;">
	<option value=""> 一级分类 </option>
	{foreach from=$cate_parent  item=boss}
	<option value="{$boss->id}" {if $boss->id == $cate_boss}selected{/if}>{$boss->name}</option>
	{/foreach}
	</select> -->
	<input type="submit" class="btn" value="搜 索" style="width:70px;" /> 
	<div class="clear"></div>
	</div>
	</form>
  </div>
<a href="###" id="change">改变分类</a>
<table id="simple-table" class="table table-striped table-bordered table-hover">
	<thead>
		<tr>
			<th style="padding:0px;"><p id='checkboss'>全选</p></th>
			<th>ID</th>
			<th>图片</th>
			<th>名称</th>
			<th>货号</th>
			<th>简要描述</th>
			<th>积分</th>
			<!-- <th>价格</th> -->
			<!-- <th>促销价、特价</th> -->
			<th>库存</th>
			<th>所属类别</th>
			<!-- <th>所属店铺</th> -->
			<th>所属品牌</th>
			<th>状态</th>
			<th>添加时间</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody>
		<form action="?app=goods&act=check_cate" method="post" id="tochange">
			<!-- 	<input type="hidden" name="app" id="app" value="goods" />
				<input type="hidden" name="act" id="act" value="check_cate" /> -->
		{foreach from=$rs item=row name=row}
		<tr>
			<td><input type="checkbox" name="checkbox[]" id="{$row.id}" value="{$row.id}" /></td>
			<td>{$row.id}</td>
			<td style="text-align:left;"><img src="{if $row.default_pic !== ''}{$row.default_pic}{else}/images/nopic.png{/if}" width="100" /></td>
			<td style="text-align:left;">{$row.name|truncate:20}</td>
			<td style="text-align:left;">{$row.huohao}</td>
			<td style="text-align:left;">{$row.description}</td>
			<td style="text-align:left;">{$row.integral}</td>
			<!-- <td style="text-align:left;">{$row.price}</td>
			<td style="text-align:left;">{$row.promote_price}</td> -->
			<td style="text-align:left;">{$row.stocks}</td>
			<td style="text-align:left;">{$row.cname}</td>
			<!-- <td style="text-align:left;">{$row.sname}</td> -->
			<td style="text-align:left;">{$row.bname}</td>
			<td style="text-align:left;">{if $row.status == 1}正常{else}下架{/if}</td>
			<td style="text-align:left;">{$row.add_time|date_format:"%Y-%m-%d"}</td>
			<td>
				<a href="index.php?app=goods&act=edit&goods_id={$row.id}&current_page={$page.current_page}&oldwhere={$oldwhere}">
					<span class="btn btn-xs btn-info">
					<i class="ace-icon fa fa-pencil bigger-120"></i>
				</span>
				</a>
				<a href="index.php?app=goods&act=delete&goods_id={$row.id}&current_page={$page.current_page}&oldwhere={$oldwhere}" class="delete">
					<span class="btn btn-xs btn-danger">
					<i class="ace-icon fa fa-trash-o bigger-120"></i>
				</span>
				</a>
			</td>
		</tr>
		{foreachelse}
		<tr bgcolor="white"><td colspan="13" height="50">暂无记录</td></tr>
		{/foreach}	
		 <!-- 弹出 -->
        <div class="modal fade" id="to-change" role="dialog" aria-labelledby="gridSystemModalLabel">
            <div class="modal-dialog row" role="document" style="margin-top:8%;">
                <div class="modal-content col-lg-8 col-lg-offset-2">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    </div>
                    <form id="receive_form" action="?app=receive&act=add" method="post">
                        <div class="modal-body">
                            <div class="container-fluid">
                            	请选择要改成的分类
                                	<select name="catechange" id="cate" class=" form-control "  data-live-search="true" style="line-heght:30px;display:inline-block;width:160px;">
										<option value=""> 分类: </option>
										{foreach from = $cate_parent item =val}
											<optgroup label="{$val->name}">
												{foreach from = $cate item =row}
													{if $row->parent_id == $val->id}
													<option value="{$row->id}" {if $cate_id == $row->id}selected{/if}>{$row->name}</option>
													{/if}
												{/foreach}
											</optgroup>
										{/foreach}
									</select>
                            </div>
                        </div>
                        <div class="modal-footer fot">
                            <button type="button" class="btn" data-dismiss="modal"> 取消 </button>
                            <button id="get-to" type="button" class="btn"> 提交 </button>
                        </div>
                    </form>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->
	</form>
	</tbody>
</table>
	<div class="mypage" style="text-align:right">
			共 {$page.num_records} 个记录  {$page.current_page} / {$page.num_pages} 页  {$page.first_page} {$page.prev} {$page.nav} {$page.next} {$page.last_page}
	</div>
{include file="footer.html"}
<script type="text/javascript">
$(function(){
	$('#endprice').blur(function(){
		var a = $(this).val();
		if( a >= 0 && a !== ''){
			$('#jiage').val(1);
		}else{
			$('#jiage').val('');
		}
	})
	$('#checkboss').click(function(){
		if($(this).hasClass('red')){
			$(this).removeClass('red');
			$(':checkbox').removeProp('checked');
		}else{
			$(this).addClass('red');
			$(':checkbox').prop('checked', true);
		}

	})
	$('#change').click(function(){
        $('#to-change').modal();
    }) 
    $('#get-to').click(function(){
        $('#tochange').submit();
    })
})
</script>
